#pragma once

#include "common.h"

#include "TSingleton.h"
#include "IInitalizable.h"

#include "File.h"
#include "Console.h"
#include "Log.h"
#include "SysCPU.h"
#include "SysRam.h"



struct LocalTime
{
	u16 year;
	u16 month;
	u16 day;
	u16 hour;
	u16 minute;
	u16 second;
	u16 milisecond;
};

//Operating system class
//Provides objects and methods to operate on different operating system aspects
class Sys : public TSingleton<Sys>, public IInitalizable
{
	friend TSingleton<Sys>;

public:
	void Init();
	void Shutdown();
	bool IsInitialized();

	LocalTime GetLocalTime();
	std::string ConvertTimeToString(LocalTime time);

	//Debug msg
	void DebugWriteLine(std::string msg);
	void DebugWriteLine(const char* msg);
	void DebugPrintf(const char* format, ...);

	//System version
	void CheckSystemVersion();
	u16 GetSystemVersion();

	//Game root directory
	void CheckRootDir();
	std::string GetRootDir();

	//Processor informations
	CPUInfo GetCpuInfo();

	//Computer memory informations
	RamInfo GetRamInfo();

	//Messagebox
	void MsgBoxInfo(const char* msg);
	void MsgBoxWarning(const char* msg);
	void MsgBoxError(const char* msg);

protected:
	Sys(void);
	~Sys(void);

private:
	bool initialized;
	bool initSuccess;

	Log mainLog;
	LocalTime sysStart;

	//System verison
	u8 majorVer;
	u8 minorVer;

	//Processor information
	CPUInfo processorInfo;
	void CheckCpu();

	//Ram information
	RamInfo ramInfo;
	void CheckRam();

	char rootDir[4096];	
};

